package com.example.day01;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.List;

public class VideoMutiAdapter extends BaseMultiItemQuickAdapter<VideoEntity.DataBean, BaseViewHolder> {
    public VideoMutiAdapter(List<VideoEntity.DataBean> data) {
        super(data);//数据中有几种type类型，就要写几个addItemType
        addItemType(0,R.layout.item_video);
        addItemType(1,R.layout.item_video1);
       /* addItemType(2,R.layout.item_video1);
        addItemType(5,R.layout.item_video1);*/
    }

    @Override
    protected void convert(BaseViewHolder holder, VideoEntity.DataBean bean) {
        switch (bean.getItemType()){
            case 0:
            {
                holder.setText(R.id.tv,bean.getCaption());
                ImageView view = holder.findView(R.id.iv);
                Glide.with(getContext()).load(bean.getVideomainimg()).into(view);
            }
            break;
            case 1:
            case 2:
            case 5:
            {
                holder.setText(R.id.tv,bean.getCaption());
                ImageView view = holder.findView(R.id.iv);
                Glide.with(getContext()).load(bean.getVideomainimg()).into(view);
                holder.setText(R.id.tv2,bean.getAuthname());
            }//当不同的值执行同一个操作时
            break;
        }
    }
}
